/*
对拦截队列进行测试的一个用例
*/

#include <stdio.h>
#include <stdlib.h>
#include "doggie.h"


int main(void)
{
	QueueHead * qh;
	LinkId lid1,lid2,lid3,lid4;
	PacketElem *pe1,*pe2,*pe3,*pe4;
	
	PacketElem *temp;
	PacketElem * ttemp;

	lid1.destIp=101;
	lid1.sourIp=201;
	lid1.destPort=50;
	lid1.sourPort=25;

	lid2.destIp=102;
	lid2.sourIp=202;
	lid2.destPort=51;
	lid2.sourPort=26;

	lid3.destIp=103;
	lid3.sourIp=203;
	lid3.destPort=52;
	lid3.sourPort=27;

	lid4.destIp=104;
	lid4.sourIp=204;
	lid4.destPort=53;
	lid4.sourPort=28;

	unsigned char parr1[5]={0x01,0x01,0x01,0x01,0x01};
	unsigned char parr2[5]={0x02,0x02,0x02,0x02,0x02};
	unsigned char parr3[5]={0x03,0x03,0x03,0x03,0x03};
	unsigned char parr4[5]={0x04,0x04,0x04,0x04,0x04};


	//打包测试
	pe1=getPack(parr1,&lid1,1,5);
	pe2=getPack(parr2,&lid2,2,5);
	pe3=getPack(parr3,&lid3,3,5);
	pe4=getPack(parr4,&lid4,4,5);


	//构造队列测试
	qh = init_intercept_queue();

	//入队测试
	enQueue(qh,pe1);
	enQueue(qh,pe2);
	enQueue(qh,pe3);
	enQueue(qh,pe4);

	//查询测试
    if((checkQueue(qh,&lid1))==1)
	{
		printf("lid search ok~!\n");
	}

	//删除测试
	temp=delOnePac(qh,&lid1);
	printf("temp->packet_id is %d\n",temp->packet_id);
	

	//删除后的效果测试
	ttemp=qh->head;
	while(ttemp!=NULL)
	{
		
		printf("curruently,queue size is %d, search is %d\n",qh->size,ttemp->packet_id);
	
		ttemp=ttemp->next;
	}


	return 0;



}
